<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>{$Think.lang.not_add}</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="INDEX/css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="INDEX/css/main.css"/>
		<link rel="stylesheet" type="text/css" href="INDEX/css/news_board.css"/>
	</head>

	<body>
		<script src="INDEX/js/mui.min.js"></script>
		<script src="INDEX/js/jquery-1.8.0.min.js" type="text/javascript" charset="utf-8"></script>
		<header class="mui-bar mui-bar-nav">
			<a href="#offCanvasSide" class="right_top"></a>
			<!--<a class="mui-switch "></a>-->
			<div class="mui-switch mui-pull-right {if $think_var=='zh-cn'}mui-active{/if}" id="mySwitch">
  				<div class="mui-switch-handle"></div>
			</div>
			<h1 class="mui-title">{$Think.lang.project_title}</h1>
		</header>
		<div id="offCanvasWrapper" class="mui-off-canvas-wrap mui-draggable mui-slide-in">
			<div id="header">{include file='header'/}</div>
			<div class="mui-inner-wrap">
				<div id="offCanvasContentScroll" class="mui-content mui-scroll-wrapper mui-slide-in">
					<div class="mui-scroll">
						<div class="news_content">
							<div class="news_content_top">
								<div style="position: relative;">
								<textarea name="question"  id="textArea" rows="10" cols="10" placeholder="{$Think.lang.not_question_input}" style="border: none;"></textarea>
								<!-- <span class='two'><span id="textNum">0</span>/200</span> -->
								</div>
								<div class="question_type">
									<label for="">{$Think.lang.not_cate}:</label>
									<input type="text" id="type_que" placeholder="{$Think.lang.not_answer_input}" readonly="readonly"/>
									<span class="mui-icon mui-icon-arrowright" style="font-size: 22px;color: #000;"></span>
								</div>
								<div class="question_list">
								  <ul>
									  {foreach $category as $cate}
									  {if condition = "$think_var eq 'zh-cn'"}
									  <!-- <li class="add_bg">请选择</li> -->
									<li class="encrypt" data="{$cate['id']}">{$cate['advisory_name']}</li>
									{else}
										<!-- <li class="add_bg">please select</li> -->
									<li class="encrypt" data="{$cate['id']}">{$cate['advisory_name_en']}</li>
									{/if}
									  {/foreach}
								  </ul>
								</div>
							</div>
							<div class="submit">{$Think.lang.set_submit}</div>
							<div class="show_my_news">{$Think.lang.not_select}</div>
						</div>
					</div>
				</div>
			</div>	
		</div>
		<script src="INDEX/js/switchover.js"></script>
		
		<!-- <script src="INDEX/js/main.js" type="text/javascript" charset="utf-8"></script> -->
		<script>
			$(function(){
					var question_type = document.getElementsByClassName("question_type")[0];
					question_type.addEventListener("tap", function () {
					$(".question_list").css("display","block")
				})
				/************************************/
					mui(".question_list").on("tap",".encrypt",function(){
						if(!$(this).hasClass("add_bg")){
							$(this).addClass("add_bg");
							$(this).siblings().removeClass("add_bg");
							$(".question_list").css("display","none");
							$("#type_que").val($(this).html())
						}
					})
					var show_my_news = document.getElementsByClassName("show_my_news")[0];
					show_my_news.addEventListener("tap", function () {
						window.location.href = "{:Url('index/notice/index')}";
					})

					var submit = document.getElementsByClassName("submit")[0];
					submit.addEventListener("tap", function () {
						var textArea = $("#textArea").val();
						if(textArea == ""){
							mui.toast("{$Think.lang.not_question_input}");
						return false;
						}
						var question = $(".question_list").find(".add_bg").attr("data");
						if(question == "")
						{
							mui.toast("{$Think.lang.not_answer_input}");
						    return false;
						}
						mui.confirm("{$Think.lang.sure_submit}","",["{$Think.lang.btn_cancel}","{$Think.lang.btn_sure}"],function(e){
							if(e.index==1){
								mui.ajax("{:Url('Notice/add')}",{
									data:{
										"textArea" : textArea,
										"question" : question,
									},
									dataType:'json',//服务器返回json格式数据
									type:'post',//HTTP请求类型
									timeout:10000,//超时时间设置为10秒；
									success:function(data){
										mui.toast(data["message"]);
										setTimeout(function(){
											window.location.reload();
										},1000)
									},
									error:function(xhr,type,errorThrown){
										//异常处理；
										console.log(type);
									}
								});
							}else{
								return false;
							}
						})
				})
			})
		</script>
	</body>

</html>